var GameTime = function () {
    var hour = 0;

    var minute = 0;

    var second = 0;

    var timer = null;

    var timeAction = function () {
        if (++second === 60) {
            if (++minute === 60) {
                hour++;
                minute = 0;
            }
            second = 0;
        }
        var strHour = hour < 10 ? ("0" + hour) : (hour + "");
        var strMinute = minute < 10 ? ("0" + minute) : (minute + "");
        var strSecond = second < 10 ? ("0" + second) : (second + "");
        document.getElementById("game-time").innerHTML = strHour + ":" + strMinute + ":" + strSecond;
    };

    this.startGameTime = function () {
        timeAction();
        timer = setInterval(function () {
            timeAction();
        }, 1000);
    };

    this.stopGameTime = function () {
        if(timer) {
            clearInterval(timer);
            timer = null;
        }
    };

    this.getMinute = function () {
        return minute;
    };
};